//
//  HggProductTableViewCell.m
//  全选和单选
//
//  Created by 胡高广 on 2017/9/18.
//  Copyright © 2017年 jinshuaier. All rights reserved.
//

#import "Zz_addressBookCell.h"
#import "UILabel+MyLable.h"

//RGB的颜色转换
#define kUIColorFromRGB(rgbValue) [UIColor \
colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 \
green:((float)((rgbValue & 0xFF00) >> 8))/255.0 \
blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]

#define WIDTH ([UIScreen  mainScreen].bounds.size.width)
#define HEIGHT ([UIScreen mainScreen].bounds.size.height)

@interface Zz_addressBookCell ()


@end

@implementation Zz_addressBookCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self ) {
        self.backgroundColor = kUIColorFromRGB(0xffffff);
        [self createView];
        
    }
    return self;
}

- (void)createView {
    self.nameLabel = [UILabel initWithText:@"壹休" withFontSize:14 WithFontColor:kUIColorFromRGB(0x666666) WithMaxSize:CGSizeMake(WIDTH - 50, 14)];
    self.nameLabel.textAlignment = NSTextAlignmentLeft;
    self.nameLabel.frame = CGRectMake(14, 18, WIDTH - 80, 14);
    [self.contentView addSubview:self.nameLabel];
    
    
    //选中按钮
    self.selectBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    self.selectBtn.frame = CGRectMake(WIDTH - 55, 5, 44, 36);
    self.selectBtn.selected = self.isSelected;
    [self.selectBtn setTitle:@"添加" forState:UIControlStateNormal];

    self.selectBtn.titleLabel.font = [UIFont systemFontOfSize:15.0f];
    self.selectBtn.backgroundColor=XMGRGBColor(1, 222, 22);
    [self.contentView addSubview:self.selectBtn];
    

    
}
+ (instancetype)cellWithTableView:(UITableView *)tableView {
    // 创建cell
    static NSString *ID = @"Zz_addressBookCell";
    Zz_addressBookCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];

    if (cell == nil) {
        cell = [[Zz_addressBookCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:ID];
    }
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}
//选中按钮点击事件
-(void)selectBtnClick:(UIButton*)button
{
    self.selectBtn.selected = !self.selectBtn.selected;
    if (self.cartBlock) {
        self.cartBlock(self.selectBtn.selected);
    }
    
}
@end
